package com.wtf.generator.exception;

import com.wtf.generator.enums.CommonErrorEnum;
import lombok.Data;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

/**
 * date: 2022/6/18 10:59
 * @author linhuanyou
 * @email 496558736@qq.com
 * @version 1.0
 */
@Data
@ToString
@Slf4j
public class CommonException extends RuntimeException{

    private int code;

    private String msg;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public CommonException(String msg) {
        super(msg);
    }

    public CommonException(String msg, Throwable error) {
        super(msg,error);
    }

    public CommonException(int code, String msg,Throwable error) {
        super(msg,error);
        this.code = code;
        this.msg = msg;
    }

    public CommonException(CommonErrorEnum commonErrorEnum){
        super(commonErrorEnum.getErrMsg());
        this.code = commonErrorEnum.getErrCode();
        this.msg = commonErrorEnum.getErrMsg();
    }

    public CommonException(CommonErrorEnum commonErrorEnum, Throwable error){
        super(commonErrorEnum.getErrMsg(),error);
        this.code = commonErrorEnum.getErrCode();
        this.msg = commonErrorEnum.getErrMsg();
    }

}
